﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 泛型处理
{
    public class sort<T> where T:IComparable
    {
        public void Mpsort(T[] a)
        {
            int i, j, n;
            n = a.Length;
            T temp;
            for(i=1;i<n;i++)
                for(j=0;j<n-i-1;j++)
                    if(a[j].CompareTo(a[j+1])>0)
                    {
                        temp = a[j];
                        a[j] = a[j + 1];
                        a[j + 1] = temp;
                    }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            sort<int> srt = new sort<int>();
            int[] b = { 2, 1, 5, 3, 4 };
            srt.Mpsort(b);
            foreach(int x in b)
            {
                Console.WriteLine("   {0}", x);
            }
        }
    }
}
